package levelSystem.levels;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import tools.Constants;
import tools.GameElement;
import tools.ImageHandler;

import levelSystem.GameLevel;
import levelSystem.MapLevel;

public class NewGame extends GameLevel{

	private BufferedImage howToPlay;
	private boolean enterPressed;
	
	public NewGame() {
		/* Change here */		
		super();
		enterPressed = false;
	}
	
    @Override
    public boolean logic() {
    	if(enterPressed && fadeFinished) 
    	{
    		MapLevel m = new MapLevel("minaLv4");
    		levelHandler.changeLevel(m, 16, 9);
    		m.addElement(new GameElement(
        			ImageHandler.addColorKey(ImageHandler.loadImage("/img/elements/droppedWeapons.png")), 
        			19*Constants.TILE_WIDTH, 19*Constants.TILE_HEIGHT, 0, 0, 
        			0, 0, 5));
    	}
        return true;
    }

    @Override
    public void renderLevel(Graphics gg) {

    	BufferedImage aux = new BufferedImage(13*Constants.TILE_WIDTH, 10*Constants.TILE_HEIGHT, BufferedImage.TRANSLUCENT);
    	Graphics g = aux.getGraphics();
    	
    	if(howToPlay != null)
    	{
    		g.drawImage(howToPlay, 0, 0, null);
    	}
    	
    	if(!fadeFinished)
    	{
    		if(fadeType == 1)
    		{
    			fadeIn(g, aux.getWidth(), aux.getHeight());
    		}else fadeOut(g, aux.getWidth(), aux.getHeight());
    	}
    	
    	gg.drawImage(aux, 0, 0, Constants.DEFAULT_SCREEN_WIDTH, Constants.DEFAULT_SCREEN_HEIGHT, null);
    	
    	g.dispose();
    	gg.dispose();
    }

    @Override
    protected void procUp(int i) {
        
    }

    @Override
    protected void procDown(int i) {
        
    }

    @Override
    protected void procLeft(int i) {
        
    }

    @Override
    protected void procRight(int i) {
        
    }

    @Override
    protected void procA(int i) {}

    @Override
    protected void procS(int i) {}

    @Override
    protected void procD(int i) {}

    @Override
    protected void procW(int i) {
        
    }

    @Override
    protected void procEnter(int i) {
    	if(!enterPressed)
    	{
    		setFadeOutComponents();
    		enterPressed = true;
    	}
    }

	@Override
	protected void showDebug(Graphics g) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		howToPlay = ImageHandler.loadImage("/img/elements/howToPlay.png");
	}

	@Override
	public void init(int x, int y) {
		// TODO Auto-generated method stub
		init();
	}
	
	@Override
	public void pauseGame() {
	}
}